package com.magicalcoder.youyamvc.core.http;

import com.magicalcoder.youyamvc.core.common.utils.MapUtil;
import com.magicalcoder.youyamvc.core.http.dto.ReqHeader;
import com.magicalcoder.youyamvc.core.http.dto.ReqReturn;
import com.magicalcoder.youyamvc.core.http.factory.HttpClientFacroty;
import com.magicalcoder.youyamvc.core.http.utils.IHttpClient;
import org.apache.http.entity.ContentType;

import java.util.Map;

/**
 * author: hedy
 * date:2018/4/27
 * function:
 */
public class HttpTest {
    public static void main(String[] args) {
        String url = "http://im.voicecloud.cn/v1/query/user/historymsg.do";
        Map<String,String> header = MapUtil.buildStringMap("X-Appid","5acd59b6","X-Token","9b96878a-2244-4801-b27f-1e81495a784d");
        String json = "{\"limit\":100,\"from\":\"201804231116517\",\"to\":\"26871088\",\"beginTime\":\"1124559552\",\"endTime\":\"1524790962\",\"sort\":1}";
        ReqHeader reqHeader = new ReqHeader();
        reqHeader.setHeaderMap(header);
        IHttpClient post = HttpClientFacroty.createPost();
        ReqReturn reqReturn = post.requestByJson(url,json, ContentType.APPLICATION_JSON,reqHeader);
        System.out.println(reqReturn.getBody());
    }
}
